<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

use Illuminate\Http\Request;
use Jenssegers\Agent\Facades\Agent;
use Illuminate\Support\Facades\Config;

Route::get('/', function () {
    if (Agent::isMobile())
        return redirect('http://wx2.97kid.com/wx');
    else
        return view('home1')->with('products', Config::get('products.products'))
            ->with('limit', \App\Http\Controllers\WxController::largeLimit());
});

// 课时购买
Route::get('/index1', function () {
    if (Agent::isMobile())
        return redirect('http://wx2.97kid.com/wx');
    else
        return view('home')->with('products', Config::get('products.products'))
            ->with('limit', \App\Http\Controllers\WxController::largeLimit());
});

Route::get('/lessonplan', function () {
    return view('home')->with('products', Config::get('products.products'))
        ->with('limit', \App\Http\Controllers\WxController::largeLimit())
        ->with('buyPlan', 'buyPlan');
});

Route::get('/course', function () {
    return view('course');
});

Route::get('/teachers', function () {
    return view('teachers');
});

Route::get('/download', function () {
    return view('download1');
});

Route::get('/download1', function () {
    return view('download');
});

Route::get('/aboutus', function () {
    return view('aboutus');
});

Route::get('/baike', function () {
    return view('baike');
});

Route::get('levelintroductionen/{level}', 'LevelIntroductionController@showLevelIntroductionEn')->where('level', '[0-9]+');
Route::get('levelintroduction/{level}', 'LevelIntroductionController@showLevelIntroduction')->where('level', '[0-9]+');


Route::get('order/{product}', function ($product) {
    return view('order.newOrder1')
        ->with(['pId' => $product, 'products' => Config::get('products.products')])
        ->with('limit', \App\Http\Controllers\WxController::largeLimit());
});

Route::get('order1/{product}', function ($product) {
    return view('order.newOrder1')
        ->with(['pId' => $product, 'products' => Config::get('products.products')])
        ->with('limit', \App\Http\Controllers\WxController::largeLimit());
});

Route::get('/verifypayment', function (Request $request) {
    $billNo = $request->input('out_trade_no');
    return view('order.verifyPayment')->with('billNo', $billNo);
});


Route::post('/token', 'LoginController@login');

Route::post('/sms/register', 'LoginController@sendRegisterSmsCode');
Route::post('/sms/reset', 'LoginController@sendResetSmsCode');

Route::post('/register', 'LoginController@register');

Route::post('/reset_password', 'LoginController@resetPassword');

Route::post('/users/me', 'LoginController@getUserDetail');

Route::post('/bills', 'OrderController@createOrder');   // 现金购买
Route::post('/bills1', 'OrderController@createOrder1'); // 课时购买

Route::get('/bills/{billNo}', 'OrderController@checkOrderStatus');   // 现金购买
Route::get('/bills1/{billNo}', 'OrderController@checkOrderStatus1'); // 课时购买

Route::post('/recommendations', 'OrderController@getRecommendations');   // 现金购买
Route::post('/recommendations1', 'OrderController@getRecommendations1'); // 课时购买

// 课程介绍
Route::get('/level', function (Request $request) {
    $lang = $request->get('lang');
    $seriesId = $request->get('seriesId');
    if ($lang === 'en') {
        return view('LevelIntroductionEn.level')->with(['lang' => $lang, 'seriesId' => $seriesId]);
    } else {
        if (Agent::isMobile()) return view('mobile.level')->with(['lang' => $lang, 'seriesId' => $seriesId]);
        else return view('LevelIntroduction.level')->with(['lang' => $lang, 'seriesId' => $seriesId]);
    }
});

Route::get('/level/{level}', 'LevelIntroductionController@showSiteLevelIntro')->where('level', '[0-9]+');

// 微信页面分组
Route::group(['prefix' => '/wx'], function () {

    // 首页
    Route::get('/', 'WxController@wxHome1');
    Route::get('/index1', 'WxController@wxHome');

    Route::get('/getwxpayconfigs', 'WxController@getPayConfigs');

    Route::get('/verifypayment1/{planId}', 'WxController@verifyPayment1');
    Route::get('/verifypayment/{planId}', 'WxController@verifyPayment');

    // 推荐赠课
    Route::get('/bonuslesson', 'WxController@bonusLesson');

    Route::get('/feedback/{appointment}', 'WxController@feedback3');
    Route::get('/feedback1/{appointment}', 'WxController@feedback1');
    Route::get('/feedback2/{appointment}', 'WxController@feedback2');
    Route::get('/feedback3/{appointment}', 'WxController@feedback3');
    Route::get('/feedback/{appointment}/review', 'WxController@feedbackReview');

    // 双11活动
    Route::get('/doubleeleven{num?}', 'WxController@doubleEleven')->where('num', '[0-9]+');
    Route::get('/doubleeleven/{num}', 'WxController@doubleEleven')->where('num', '[0-9]+');
    Route::get('/{num}/doubleeleven/{status}', 'WxController@doubleEleven');

    // 礼品卡兑换
    Route::get('/redeemcard', 'WxController@redeemCard');

    // 圣诞节
    Route::get('/christmas{num?}', 'WxController@christmas')->where('num', '[0-9]+');
    Route::get('/christmas/{num}', 'WxController@christmas')->where('num', '[0-9]+');
    Route::get('/{num}/christmas/{status}', 'WxController@christmas');

    // 复活节
    Route::get('/easter/branding', 'WxController@easter1');
    // 复活节
    Route::get('/easter{num?}', 'WxController@easter')->where('num', '[0-9]+');
    Route::get('/easter/{num}', 'WxController@easter')->where('num', '[0-9]+');
    Route::get('/{num}/easter/{status}', 'WxController@easter');

    // 拼读课团购
    Route::get('/phonicsextra{num?}', 'WxController@phonicsExtra')->where('num', '[0-9]+');
    Route::get('/phonicsshare{num?}', 'WxController@phonicsShare')->where('num', '[0-9]+');
    Route::get('/phonics{num?}', 'WxController@phonics')->where('num', '[0-9]+');
    Route::get('/phonics/{num}', 'WxController@phonics')->where('num', '[0-9]+');
    Route::get('/{num}/phonics/{status}', 'WxController@phonics');
    Route::get('/phonics/verifypayment', function () {
        return view('mobile.campaign.phonics.verifyPayment');
    });

    // 两人班团购
    Route::get('/two{num?}', 'WxController@two')->where('num', '[0-9]+');
    Route::get('/two/{num}', 'WxController@two')->where('num', '[0-9]+');
    Route::get('/{num}/two/{status}', 'WxController@two');

    // 寒假课
    Route::get('/winterclass{num?}', 'WxController@winterClass');

    // 暑假团购(单独购2)
    Route::get('/summer3s{num?}', 'WxController@summer3s')->where('num', '[0-9]+');
    Route::get('/summer3s/{num}', 'WxController@summer3s')->where('num', '[0-9]+');
    Route::get('/{num}/summer3s/{status}', 'WxController@summer3s');

    // 暑假团购(单独购1)
    Route::get('/summer2s{num?}', 'WxController@summer2s')->where('num', '[0-9]+');
    Route::get('/summer2s/{num}', 'WxController@summer2s')->where('num', '[0-9]+');
    Route::get('/{num}/summer2s/{status}', 'WxController@summer2s');

    // 暑假团购(第二波)
    Route::get('/summers{num?}', 'WxController@summers')->where('num', '[0-9]+');
    Route::get('/summers/{num}', 'WxController@summers')->where('num', '[0-9]+');
    Route::get('/{num}/summers/{status}', 'WxController@summers');

    // 暑假团购(第一波)
    Route::get('/summer{num?}', 'WxController@summer')->where('num', '[0-9]+');
    Route::get('/summer/{num}', 'WxController@summer')->where('num', '[0-9]+');
    Route::get('/{num}/summer/{status}', 'WxController@summer');

    // 昆虫课团购
    Route::get('/insect/separately{num?}', 'WxController@insect1')->where('num', '[0-9]+');
    Route::get('/insect/separately/{num}', 'WxController@insect1')->where('num', '[0-9]+');
    Route::get('/{num}/insect/separately/{status}', 'WxController@insect1');

    // 昆虫课团购
    Route::get('/insect{num?}', 'WxController@insect')->where('num', '[0-9]+');
    Route::get('/insect/{num}', 'WxController@insect')->where('num', '[0-9]+');
    Route::get('/{num}/insect/{status}', 'WxController@insect');

    // 寒假课2
    Route::get('/winterclass2', 'WxController@winterClass2');
    // 寒假课3
    Route::get('/winterclass3', 'WxController@winterClass3');

    // 课程介绍
    Route::get('/level', function () {
        if (Agent::isMobile()) return view('mobile.level');
        else return view('LevelIntroduction.level');
    });

    // 日历领取页面
    Route::get('/calendarpresent', 'WxController@calendarPresent');

    // 大单团购页面
    Route::get('/award{num?}', 'WxController@award')->where('num', '[0-9]+');

    // 课后报告
    Route::get('/class', 'WxController@classReport');
    // 单元报告
    Route::get('/unit', 'WxController@unitReport');

    // 账户升级
    Route::get('/upgrade', 'WxController@upgrade');

    // 打卡页面
    Route::get('/achievement/clocks/{clockId}', 'WxController@achievementClocks');
    Route::get('/achievement/clocks/{clockId}/share', 'WxController@achievementClocksShare');

    // 查看自己当前任务
    Route::get('/achievement', 'WxController@achievement');

    // 设定目标
    Route::get('/achievement/new', 'WxController@newAchievement');

    // 久趣英语服务号
    Route::get('/subscribe', 'WxController@subscribe');

    // 绘本课后练习音频
    Route::get('/books/lessons/{id}/{type}/{hash?}', function () {
        return view('mobile.book.lesson');
    })->where(['id' => '[0-9]+', 'type' => '(sb|wb)']);

    // 老用户邀请新用户 赠一得二
    Route::get('/invite', 'WxController@invite');
    Route::get('/invite/share', 'WxController@inviteShare');

    // 优学派课时兑换
    Route::get('/yxp/redeem', 'WxController@yxpRedeem');
    // 优学派优惠券兑换
    Route::get('/yxp/coupon', 'WxController@yxpCoupon');

    // 地推人员
    Route::get('/sales/media', 'WxController@salesMedia');

    // 微信朋友圈推广购买详情页
    Route::get('/friend', 'WxController@friend');

    // 1元8人抽奖
    Route::get('/lottery{num?}', 'WxController@lottery')->where('num', '[0-9]+');
    Route::get('/lottery/result', 'WxController@lotteryResult');
    Route::get('/lottery/verifypayment', function () {
        return view('mobile.campaign.lottery.verifypayment');
    });

    // 1v1
    Route::get('/one{num?}', 'WxController@one')->where('num', '[0-9]+');
    Route::get('/1one{num?}', 'WxController@one1')->where('num', '[0-9]+');
    Route::get('/2one{num?}', 'WxController@one2')->where('num', '[0-9]+');

    // order
    Route::get('/order{num?}', 'WxController@order')->where('num', '[0-9]+');
    Route::get('/1order{num?}', 'WxController@order1')->where('num', '[0-9]+');
    Route::get('/3order{num?}', 'WxController@order3')->where('num', '[0-9]+');

    // verify
		Route::get('/verify{num?}', 'WxController@verify')->where('num', '[0-9]+');

		// verify
    Route::get('/10verify{num?}', 'WxController@verify10')->where('num', '[0-9]+');

    // lucky-bag
    Route::get('/lucky-bag{num?}', 'WxController@luckyBag')->where('num', '[0-9]+');

    // tenTimesLesson
    Route::get('/ten-times-lesson{num?}', 'WxController@tenTimesLesson')->where('num', '[0-9]+');


    // zero-three
    Route::get('/zero-three{num?}', 'WxController@zeroThree')->where('num', '[0-9]+');
    Route::get('/invite-one{num?}', 'WxController@inviteOne')->where('num', '[0-9]+');
    Route::get('/invite-one-result{num?}', 'WxController@inviteOneResult')->where('num', '[0-9]+');

    // 百度品牌专区
    Route::get('/brand/{vip}', 'WxController@brand1');
    Route::get('/brand1/{vip}', 'WxController@brand');

    // 长期报名课
    Route::get('/{vip}', 'WxController@wxHome1');

    Route::post('/error', 'WxController@logError');

    Route::get('/assistant/{name}', 'WxController@assistant');

});
